/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jsf.bean.client;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author Administrator
 */
@ManagedBean
@RequestScoped
public class FeedBackBean_c {
    private int feedback_Id;
    private String name;
    private String email;
    private String feedback_Title;
    private String feedback_Text;
    private String created_Time;
    private int feedback_Status;

    public Connection getConn() {
        return conn;
    }

    public void setConn(Connection conn) {
        this.conn = conn;
    }

    public String getCreated_Time() {
        return created_Time;
    }

    public void setCreated_Time(String created_Time) {
        this.created_Time = created_Time;
    }

    public int getFeedback_Id() {
        return feedback_Id;
    }

    public void setFeedback_Id(int feedback_Id) {
        this.feedback_Id = feedback_Id;
    }

    public int getFeedback_Status() {
        return feedback_Status;
    }

    public void setFeedback_Status(int feedback_Status) {
        this.feedback_Status = feedback_Status;
    }

    public String getFeedback_Text() {
        return feedback_Text;
    }

    public void setFeedback_Text(String feedback_Text) {
        this.feedback_Text = feedback_Text;
    }

    public String getFeedback_Title() {
        return feedback_Title;
    }

    public void setFeedback_Title(String feedback_Title) {
        this.feedback_Title = feedback_Title;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    

    
    
    /**
     * Creates a new instance of FeedBackBean_c
     */
    public FeedBackBean_c() {
    }
    
    Connection conn;
    public void addFeedBack() throws SQLException, ClassNotFoundException{
        conn = JDBCUtil.MyConn.getConnection();
        
        String sql ="insert into FeedBacks values(?,?,?,?,?,?)";
        
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
                Date date = new Date();
        
        //String getdate = dateFormat.format(date);
        
        PreparedStatement pst = conn.prepareStatement(sql);
        pst.setNString(1, name);
        pst.setNString(2, email);
        pst.setNString(3, feedback_Title);
        pst.setString(4, feedback_Text);
        pst.setTimestamp(5, new java.sql.Timestamp(date.getTime()));
        pst.setInt(6, 1);
        
        pst.execute();
        clear();
    } 
    
    public void clear(){
        setName("");
        setEmail("");
        setFeedback_Title("");
        setFeedback_Text("");
    }
    public String goback(){
        return "register.xhtml?faces-redirect=true";
    }
}
